#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll N=1e7;
vector<ll> arr(N);
ll n,k,sum,count1;
int main()
{
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  cin>>n>>k;
  for(ll i=1;i<=n;++i)
  {
    cin>>arr[i];
  }
  sort(arr.begin()+1,arr.begin()+1+n);
  for(ll i=1;i<=n;++i)
  {
    if(sum+arr[i]<=k)
    {
      sum+=arr[i];
      count1++;
    } 
    else break;
  }
  if((sum+arr[count1+1]/2<=k)&&count1<n) count1++;
  cout<<count1;
  return 0;
}
